package com.example.chenliang;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/*
RestController 相当于@ResponseBody + @Controller
*/
@RestController
@RequestMapping("/chenliang")
public class HelloController {

    @RequestMapping("/hello")
    //localhost:8080/chenliang/hello  访问路径
    public String sayHello(){
        return  "hello";
    }

    //读取配置文件里面的信息
    @Value("${pageSize}")
    private Integer pageSize;

    @Value("${devName}")
    private String devName;

    //http://localhost:8081/chenliang/showInfo
    @RequestMapping(value = "/showInfo",method = RequestMethod.GET)
    public String showInfo(){
        return "pageSize:" + pageSize + ",devName:" + devName;
    }

    @Value("${content}")
    private String content;
    @RequestMapping(value = "/content",method = RequestMethod.GET)
    public String showContent(){
        return content;
    }

    //读取对象
    @Autowired
    private Developer developer;
    @RequestMapping(value = "/developer",method = RequestMethod.GET)
    public  String showDeveloper(){
        return  developer.toString();
    }
}
